from typing import *


class Solution:
    def numsGame(self, nums: List[int]) -> List[int]:
        mod = 1000000007
        ans = [0] * len(nums)
        sms = [0] * len(nums)
        sms[0] = nums[0]
        for i in range(1, len(nums)):
            sms[i] = sms[i - 1] + nums[i]
        for i, v in enumerate(nums):
            m = i // 2
            ans[i] += abs(
                (nums[m] + nums[m] + i - m) * (i - m + 1) // 2
                - (sms[i] - (sms[m - 1] if m > 0 else 0))
            )
            ans[i] += abs(
                (nums[m] - m + nums[m] - 1) * 
                m // 2 - (sms[m - 1] if m > 0 else 0)
            )

        return ans


s = Solution()
print(s.numsGame([1, 1, 1, 2, 3, 4]))
print(s.numsGame([1, 2, 3, 4, 5]))
case = []
from random import randint

for i in range(20):
    case.append(randint(0, 200))
print(sorted(case))
